﻿#pragma once

#include "precomp.h"
#include "sound.h"


class EndingMovie{
public:
	EndingMovie();
	~EndingMovie();
	void Load(CL_GraphicContext &gc, CL_ResourceManager &resources, CL_String name);
	void Start();
	void Stop();
	void Update();
	void draw(CL_GraphicContext &gc, float x, float y);
private:
	unsigned int current_frame;
	unsigned int n_frames;
	int playing;
	CL_String song;

	CL_VirtualDirectory mov_dir;
	CL_String frame_prefix;
	unsigned int len;

	std::vector<unsigned int> _frames;
	std::vector<unsigned int> _times;
	CL_Texture _textures[32];
	int _tex_indexes[32];

	CL_Thread loader_thread;
	CL_Mutex load_mutex;
	int next_tex;
	int buffering;
	int initialized;

	void fill_buffer();
};
